// ActionScript file
package com.app.business{
	import com.adobe.cairngorm.business.ServiceLocator;
	import com.app.factories.TugasAkhirFactory;
	import com.app.model.ModelLocator;
	import com.app.vo.TugasAkhirVO;
	
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;
	
	public class TugasAkhirDelegate implements IResponder{
		private var responder:IResponder;
		private var service:HTTPService;
		private var taVo:TugasAkhirVO;
		private var Com:String;
		private var Act:String;
		private var Param:String;
		private var rs:Array;
		
		public function TugasAkhirDelegate(responder:IResponder){
			this.responder = responder;
			this.service = ServiceLocator.getInstance().getHTTPService("services");
			this.rs=new Array();
		}
		public function getDataComboTugasAkhir(taVo:TugasAkhirVO):void{
			Param=taVo.taMhsId;
			Act="getDataComboTugasAkhir";
			Com="tugas_akhir";
			var token:AsyncToken= service.send({com:Com, act:Act,params:Param});
			token.addResponder(this);
			this.taVo=taVo;
		}
		
		public function getDataTugasAkhirById(taVo:TugasAkhirVO):void{
			Param=taVo.taId;
			//Alert.show(Param);
			Act="getDataTugasAkhirById";
			Com="tugas_akhir";
			var token:AsyncToken= service.send({com:Com, act:Act,params:Param});
			token.addResponder(this);
			this.taVo=taVo;
		}
		
		public function result(dt:Object):void{
			var event:ResultEvent= ResultEvent(dt);
			//Alert.show(event.result as String);
			 if(event.result!='false'){
            	if(Act=='getDataComboTugasAkhir'){
            	    this.taVo=TugasAkhirFactory.buildDataComboTugasAkhir(event.result as String,this.taVo);
                    responder.result(this.taVo);
                }else if(Act=='getDataTugasAkhirById'){
                	//Alert.show(event.result as String);
            	    this.taVo=TugasAkhirFactory.buildDetilDataTugasAkhir(event.result as String,this.taVo);
                    responder.result(this.taVo);
                }
            }else{
                responder.fault(null);
            } 
		}
		public function fault(info:Object):void{
            var err:FaultEvent=FaultEvent(info);
            ModelLocator.getInstance().tugas_akhir.statusMessage="fail";
		}
		
	}
}